export default {
  name: "breakAppoint",
  components: {
    resumeDetail: () => import("../../../component/resumeDetail/index.vue"),
    companyDetail: () => import("../../socical/socialCheck/check.vue")
  },
  props:['totalNum'],
  data() {
    return {
      tabs: [
        {
          label: "待处理",
          status: "1"
        },
        {
          label: "已处理",
          status: "2"
        }
      ],
      btnAuthority: {},
      loading: false,
      tableData: [],
      form: {
        companyid: "",
        type: "1", // 1-> 未处理, 2-> 已处理
        starttime: "",
        endtime: "",
        pagenum: 1,
        pagesize: 10
      },
      total: 0,
      dialogVisible: false,
      dialogVisible1: false,
      dialogVisible2: false,
      dialogVisible3: false,
      userid: "",
      nickName: "",
      companyid: "",
      companyname: "",
      params: {
        reviewid: "",
        // checked: false,
        type: null,
        note: ""
      },
      abnormaldetail: {},
      signTime: [] //扫码签到时间列表
    };
  },
  created() {
    this.getTableData();
    this.btnAuthority = this.GLOBAL.powerAllBtn.yccl;
  },
  methods: {
    // 时间比较
    compareDate() {
      let starttime = Date.parse(this.form.starttime);
      let endtime = Date.parse(this.form.endtime);
      if (starttime > endtime) {
        this.$message({
          message: "开始时间不能大于结束时间",
          type: "error"
        });
        return false;
      } else {
        return true;
      }
    },
    clickTab(item) {
      this.form.type = item.status;
      (this.form.starttime = ""),
        (this.form.endtime = ""),
        (this.form.pagenum = 1),
        (this.form.pagesize = 10),
        this.getTableData();
    },
    getTableData() {
      if (!this.compareDate()) {
        return;
      } else {
        this.loading = true;
        this.$axios
          .post("/app/v1/platform/abnormal/breakInterviewList", this.form)
          .then(res => {
            this.loading = false;
            if (res.data.code === 1) {
              this.tableData = res.data.data.list;
              this.total = +res.data.data.totalnum;
			  if(this.form.type == 1){this.$emit('update:totalNum',res.data.data.totalnum)};
            } else {
              this.$message({
                message: res.data.message,
                type: "error"
              });
            }
          });
      }
    },
    query() {
      (this.form.pagenum = 1), this.getTableData();
    },
    // 查看会员详情
    handleClickNickName(row) {
      this.userid = row.userid;
      this.nickName = row.nickname;
      this.dialogVisible1 = true;
    },
    // 查看公司详情
    handleClickCompanyName(row) {
      this.companyid = row.companyid;
      this.companyname = row.companyname;
      this.dialogVisible2 = true;
    },
    // 处理异常
    handleAabnormal(row) {
      this.abnormaldetail = row;
      this.params.reviewid = row.reviewid;
      this.getTime(row.reviewid);
    },
    //获取扫码时间
    getTime(id) {
      let obj = {
        pagenum: 1,
        pagesize: 5,
        reviewid: id
      };
      this.$axios
        .post("/app/v1/platform/company/interviewScanCodeList", obj)
        .then(resp => {
          this.signTime = resp.data.data.list;
          this.dialogVisible = true;
        });
    },
    submit() {
      // if(!this.params.type) return this.$message.error('请选择异常处理操作')
      this.$confirm("此操作将处理该异常, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$axios
            .post("/app/v1/platform/abnormal/breakInterviewCommit", this.params)
            .then(res => {
              if (res.data.message === "success.") {
                this.$message({
                  message: "处理成功!",
                  type: "success"
                });
              } else {
                this.$message({
                  message: res.data.message,
                  type: "error"
                });
              }
              this.dialogVisible = false;
              this.getTableData();
            });
        })
        .catch(() => {
          // console.log('已取消操作');
        });
    },
    closeDialog() {
      this.abnormaldetail = {};
      this.params.reviewid = "";
      this.params.type = null;
      this.params.note = "";
    },
    handleClickDetails(row) {
      this.abnormaldetail = row;
      this.dialogVisible3 = true;
    },
    handleReport(row) {
      let params = {
        isShow: true,
        id: row.reviewid,
        reporttype: "10"
      };
      this.$emit("getReportDialogVisible", params);
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagesize = val;
      this.getTableData();
    }
  }
};
